import 'package:flutter/material.dart';
import 'package:flutter_soundmagus/page/eq/eq_controller.dart';
import 'package:flutter_soundmagus/util/util.dart';
import 'package:flutter_soundmagus/widget/enable_container.dart';
import 'package:flutter_soundmagus/widget/zfbutton.dart';
import 'package:get/get.dart';

import '../../../model/data_mng.dart';
import '../../../widget/menu_bottom_bar.dart';

class EqNav extends GetView<EqController> {
  const EqNav({Key? key}) : super(key: key);

  static List<String> kNavTitles = [
    ...List.generate(
        4, (index) => 'Grouping\nCH${index * 2 + 1}&${index * 2 + 2}'),
    'EQ LOCK',
    // '',
    'Reset EQ',
  ];

  @override
  Widget build(BuildContext context) {
    final selColor = Theme.of(context).primaryColor;
    return MenuBottomBar(
      title: 'Equalizer',
      left: kNavTitles.sublist(0, 4).map((e) {
        final i = kNavTitles.indexOf(e);
        return Obx(() => EnableContainer(
              enable: !controller.bottomSelects[4].value,
              child: GroupLinkButton(
                onPressed: () => controller.onBottomNavPress(i),
                onLongPress: () => controller.onBottomNavLongPress(i),
                linked: controller.bottomSelects[i].value,
                title1: DataMng.shared.chNames[i * 2].value,
                title2: DataMng.shared.chNames[i * 2 + 1].value,
              ),
            ));
      }).toList(),
      right: kNavTitles.sublist(4).map((e) {
        final i = kNavTitles.indexOf(e);
        return GestureDetector(
          onTap: () => controller.onBottomNavPress(i),
          onLongPress: () => controller.onBottomNavLongPress(i),
          child: Obx(() => EnableContainer(
                enable: i == 4 ? true : !controller.bottomSelects[4].value,
                child: Text(
                  e.isEmpty ? controller.preset.value : e,
                  textAlign: TextAlign.center,
                  style: TextStyle(
                      color: controller.bottomSelects[i].value
                          ? Theme.of(context).primaryColor
                          : Colors.white,
                      fontSize: e.isEmpty ? 10 : 12),
                ),
              )),
        );
      }).toList(),
    );
  }
}
